<?php
/**
 * @user:andy
 * @date:2021/7/5
 * @company:http://www.sjdphp.com
 * @desc:
 */

namespace app\admin\controller;


use app\common\controller\BackBaseController;
use app\common\lib\CommonClass;
use app\common\server\Json;

class Upload extends BackBaseController
{
    public function uploads(){
        if($this->request->isPost()){
            ## 获取上传的文件数据
            $file = $this->request->file("file");

            ## 调用文件上传类库
            $imgClass = CommonClass::imgClass();
            $class = CommonClass::initClass("localhost",$imgClass);
            $res = $class::uploadImg($file);

            return json($res);
        }else{
            return Json::error("请求方式错误");
        }
    }


    public function kindUploadImage(){
        ## 获取上传的文件数据
        $file = $this->request->file("imgFile");
        ## 调用文件上传类库
        $imgClass = CommonClass::imgClass();
        $class = CommonClass::initClass("localhost",$imgClass);
        $res = $class::uploadKindImg($file);

        return jsonp($res);
    }
}